/*
 * Copyright 北京航空航天大学  @ 2015 版权所有
 */
package com.buaa.edu.leetcode.algorithm.string;

/**
 * <p>正则表达式的匹配</p>
 * @author towan
 * @email tongwenzide@163.com
 * 2015年5月19日
 */
public class RegularExpressionMatching {

    public boolean isMatch(String s, String p) {
        return s.matches(p);
    }
    public static void main(String[] args) {
//        isMatch("aa","a") → false
//        isMatch("aa","aa") → true
//        isMatch("aaa","aa") → false
//        isMatch("aa", "a*") → true
//        isMatch("aa", ".*") → true
//        isMatch("ab", ".*") → true
//        isMatch("aab", "c*a*b") → true
        RegularExpressionMatching match = new RegularExpressionMatching();
        System.out.println(match.isMatch("aa","a"));
        System.out.println(match.isMatch("aa","aa"));
        System.out.println(match.isMatch("aaa","aa"));
        System.out.println(match.isMatch("aa", "a*"));
        System.out.println(match.isMatch("ab", ".*"));
//        System.out.println(match.isMatch("aa", "*")); //WHY
        System.out.println();
    }
}
